<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>xiarikui管理后台</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link href="/Public/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/Public/bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="/Public/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
    <link href="/Public/dist/css/skins/_all-skins.min.css" rel="stylesheet" type="text/css" />
    <link href="/Public/plugins/iCheck/flat/blue.css" rel="stylesheet" type="text/css" />
    <link href="/Public/Admin/css/unify.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="/Public/images/favicon.ico" type="image/x-icon" />
    <script src="/Public/js/jQuery-2.1.4.min.js"></script>
    <script src="/Public/js/global.js"></script>
    <script src="/Public/js/myFormValidate.js"></script>
    <script src="/Public/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/Public/js/layer/layer-min.js"></script>
    <script src="/Public/js/myAjax.js"></script>
    <script type="text/javascript">
    function delfunc(obj) {
        layer.confirm('确认删除？', {
            btn: ['确定', '取消']
        }, function() {
            $.ajax({
                type: 'post',
                url: $(obj).attr('data-url'),
                data: {
                    act: 'del',
                    del_id: $(obj).attr('data-id')
                },
                dataType: 'json',
                success: function(data) {
                    if (data == 1) {
                        layer.msg('操作成功', {
                            icon: 1
                        });
                        $(obj).parent().parent().remove();
                    } else {
                        layer.msg(data, {
                            icon: 2,
                            time: 2000
                        });
                    }
                    layer.closeAll();
                }
            });
        }, function(index) {
            layer.close(index);
            return false;
        });
    }

    //全选
    function selectAll(name, obj) {
        $('input[name*=' + name + ']').prop('checked', $(obj).checked);
    }

    function get_help(obj) {
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            shade: 0.3,
            area: ['90%', '90%'],
            content: $(obj).attr('data-url')
        });
    }

    function delAll(obj, name) {
        var a = [];
        $('input[name*=' + name + ']').each(function(i, o) {
            if ($(o).is(':checked')) {
                a.push($(o).val());
            }
        });
        if (a.length == 0) {
            layer.alert('请选择删除项', {
                icon: 2
            });
            return;
        }
        layer.confirm('确认删除？', {
            btn: ['确定', '取消']
        }, function() {
            $.ajax({
                type: 'get',
                url: $(obj).attr('data-url'),
                data: {
                    act: 'del',
                    del_id: a
                },
                dataType: 'json',
                success: function(data) {
                    if (data == 1) {
                        layer.msg('操作成功', {
                            icon: 1
                        });
                        $('input[name*=' + name + ']').each(function(i, o) {
                            if ($(o).is(':checked')) {
                                $(o).parent().parent().remove();
                            }
                        });
                    } else {
                        layer.msg(data, {
                            icon: 2,
                            time: 2000
                        });
                    }
                    layer.closeAll();
                }
            });
        }, function(index) {
            layer.close(index);
            return false;
        });
    }
    </script>
    <style type="text/css">
        .table > thead:first-child > tr:first-child > th{
            border-bottom: 0 none;
        } 
    </style>
</head>

<body>

<div class="wrapper">
    <div class="breadcrumbs" id="breadcrumbs">
    <ol class="breadcrumb">
        <?php if(is_array($navigate_admin)): foreach($navigate_admin as $k=>$v): ?><li><?php echo ($k); ?></li><?php endforeach; endif; ?>
    </ol>
</div>

    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
<!--                    <div class="box-header">
                        <nav class="navbar navbar-default">
                            <div class="collapse navbar-collapse">
                                <form class="navbar-form form-inline" action="<?php echo U('Tools/regionHandle');?>" method="post">
                                    <div class="form-group">
                                        <label class="control-label" for="input-mobile">增加地区</label>
                                        <div class="input-group">
                                            <input type="hidden" name="level" value="<?php echo ($parent["level"]); ?>">
                                            <input type="hidden" name="parent_id" value="<?php echo ($parent["id"]); ?>">
                                            <input type="text" name="name" class="form-control" placeholder="请输入地区">
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-primary">确定</button>
                                    <?php if($parent[level] > 0): ?><div class="form-group pull-right">
                                            <a href="<?php echo U('Tools/region',array('parent_id'=>$parent[parent_id]));?>" class="btn btn-primary pull-right"><i class="fa fa-reply"></i> 返回上一级</a>
                                        </div><?php endif; ?>
                                </form>
                            </div>
                        </nav>
                    </div>-->
                    <div class="box-body">
                        <div class="row">
                            <div class="col-sm-12">
                                <table id="list-table" class="table table-bordered table-striped dataTable">
                                    <tbody>
                                        <tr role="row" align="center">
                                            <?php if(is_array($region)): foreach($region as $k=>$vo): if($k%3 == 0): ?></tr>
                                        <tr><?php endif; ?>
                                            <td>
                                                <label class="margin"><?php echo ($vo["name"]); ?></label>
                                                <span class = 'fr'>
                                                <?php if($vo[level] < 4): ?><a href="<?php echo U('Tools/region',array('parent_id'=>$vo[id]));?>" class="btn btn-info" role="button">管理</a> &nbsp;&nbsp;<?php endif; ?>
                                                <a href="javascript:;" data-url="<?php echo U('Tools/regionHandle',array('id'=>$vo[id]));?>" onclick="delRegion(this)" class="btn btn-default" role="button">删除</a>
                                                </span>
                                            </td><?php endforeach; endif; ?>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<script type="text/javascript">
function delRegion(obj) {
    layer.confirm('确定删除此地区？', {
        icon: 3,
        title: '提示删除'
    }, function(index) {
        layer.close(index);
        window.location.href = $(obj).attr('data-url');
    });
}
</script>
</body>

</html>